﻿// For an introduction to the Blank template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232509
(function () {
    "use strict";

    var app = WinJS.Application;
    var activation = Windows.ApplicationModel.Activation;

    var canvas, context;
    var gameStage;
    var preloadQ;
    var logoScreenImage, backgroundImage;
    var logoScreenBitmap, backgroundBitmap;
    var shipImage, tankImage, airplanImage, soldierImage;
    var shipBitmap, tankBitmap, airplanBitmap, soldierBitmap;
    var shipEnemyImage, tankEnemyImage, airplanEnemyImage, soldierEnemyImage;
    var shipEnemyBitmap, tankEnemyBitmap, airplanEnemyBitmap, soldierEnemyBitmap;
    var startbt_1Image, startbt_2Image;
    var startbt_1Bitmap, startbt_2Bitmap;
    var soldier, airplan, Tankbattle, ship;
    var soldierEnemy, airplanEnemy, tankEnemy, shipEnemy;
    var player;
    var greatBase;
    var scaleX = window.innerWidth / 1920;
    var scaleY = window.innerHeight / 1080;
    var newGame = true;
    var battle = false;
    var unit = new Array();
    var unitEnemy = new Array();
    var memposition = new Array();
    var mempositionEnemy = new Array();
    var memPositionBattle = new Array();
    var memPositionEnemyBattle = new Array();
    var position = [];
    var Battle = new Array();
    var BattleEnemy = new Array();
    var count_click = 0;
    var move = 303;
    var max, maxEnemy, sum_max;
    var numShoot;
    var remove = new Array();
    var removeEnemy = new Array();
    var index;
    var timeText, min = 0, sec = 0, timeCount = 0;
    var statusText, msg;
    var pointText;
    var battlefield = false;

    var logoImage, logoBitmap;
    var newGame = true;
    var player;
    var floorImage, floorBitmap;
    var playerIdleImage, playerIdleBitmap;
    var scaleW = window.innerWidth / 1366;
    var scaleH = window.innerHeight / 768;
    var scoreText;
    var playerScore = 0;
    var gameOver;
    var H = new H;
    var aircraft_carrier = new aircraft_carrier;
    var assault_ship = new assault_ship;
    var submarine = new submarine;
    var bomber_aircraft = new bomber_aircraft;
    var anti_aircraft_tank = new anti_aircraft_tank;
    var light_tank = new light_tank;
    var hight_M_vehicle = new hight_M_vehicle;
    var light_armo = new light_armo;
    var tank = new tank;
    var soilder = new soilder;
    var fighter = new fighter_aircraft;
    var bgshopbitmap , bgshopimage;

    var fighterbitmap;

    var showPic, showPrice;
    var player = {
        goldscore: null,
        ricescore: null,
        oilscore: null,
        ironscore: null,

        iron: 500000,
        rice: 500000,
        gold: 10000,
        oil: 500000,

        fighter: 100,
        H: 100,
        aircraft_carrier: 230,
        assault_ship: 120,
        submarine: 400,
        bomber_aircraft: 12,
        anti_aircraft_tank: 100,
        light_tank: 232,
        hight_M_vehicle: 12,
        light_armo: 32,
        tank: 45,
        soilder: 12
    }

    var figheramong, fighterbitmap;
    var helbitmap, helamong;

    var mytankbitmap, mytankamong;
    var mylight_tankbitmap, mylight_tankamong;
    var mylight_armobitmap, mylight_armoamong;
    var myanti_aircraftbitmap, myanti_aircraftamong;
    var myaircraft_carrierbitmap, myaircraft_carrieramong;
    var myassault_shipbitmap, myairassault_shipamong;
    var mysoldierbitmap, mysoldieramong;

    var shop = true, battle = false;

    var Px = 792, Py = 66;

    app.onactivated = function (args) {
        if (args.detail.kind === activation.ActivationKind.launch) {
            if (args.detail.previousExecutionState !== activation.ApplicationExecutionState.terminated) {
                // TODO: This application has been newly launched. Initialize
                // your application here.
            } else {
                // TODO: This application has been reactivated from suspension.
                // Restore application state here.
            }
            args.setPromise(WinJS.UI.processAll());
        }
    };

    app.oncheckpoint = function (args) {
        // TODO: This application is about to be suspended. Save any state
        // that needs to persist across suspensions here. You might use the
        // WinJS.Application.sessionState object, which is automatically
        // saved and restored across suspension. If you need to complete an
        // asynchronous operation before your application is suspended, call
        // args.setPromise().
    };

    document.addEventListener("DOMContentLoaded", initialize, false);

    app.start();

    function Soldier(gfx) {
        this.resource = 100;
        this.rate_fire;
        this.damage = 1;
        this.range = 250;
        this.mobility = 0.08;
        this.health;
        this.elusiveness = 8;
        this.accuracy = 2;
        this.onShoot = false;
        this.choose = true;
        this.bounty = 1;
        this.bitmap = gfx;
        this.positionX;
        this.myshoot;
        this.healthText;
        this.assign_shoot = function (unt) {
            this.myShoot = window.setTimeout(function () { unt.onShoot = true; }, 3000);
        }
        this.assign_health = function () {
            this.health = this.damage * this.resource;
            this.healthText = new createjs.Text(this.health, "15px sans-serif", "blue");
            this.healthText.x = this.bitmap.x;
            this.healthText.y = this.bitmap.y;
            gameStage.addChild(this.healthText);
        }
        this.shooting = function (unt) {
            var numShooted;
            var dead;
            //numShooted = this.resource * this.damage + this.resource * Math.cos((this.elusiveness / accuracy) % (Math.PI / 2) + (Math.PI / 2));
            numShooted = (unt.resource * unt.damage) / this.elusiveness;
            return numShooted;
        }
    }

    function Tank(gfx) {
        this.resource = 100;
        this.rate_fire;
        this.damage = 3;
        this.range = 350;
        this.mobility = 0.1;
        this.health;
        this.elusiveness = 5;
        this.accuracy = 5;
        this.onShoot = false;
        this.choose = true;
        this.bounty = 2;
        this.positionX;
        this.bitmap = gfx;
        this.myShoot
        this.assign_shoot = function (unt) {
            this.myShoot = window.setTimeout(function () { unt.onShoot = true; }, 5000);
        }
        this.assign_health = function () {
            this.health = this.damage * this.resource;
            this.healthText = new createjs.Text(this.health, "15px sans-serif", "blue");
            this.healthText.x = this.bitmap.x;
            this.healthText.y = this.bitmap.y;
            gameStage.addChild(this.healthText);
        }
        this.shooting = function (unt) {
            var numShooted;
            var dead;
            //numShooted = this.resource * this.damage + this.resource * Math.cos((this.elusiveness / accuracy) % (Math.PI / 2) + (Math.PI / 2));
            numShooted = (unt.resource * unt.damage) / this.elusiveness;
            return numShooted;
        }
    }

    function Airplan(gfx) {
        this.resource = 100;
        this.rate_fire;
        this.damage;
        this.range = 600;
        this.mobility;
        this.health;
        this.elusiveness;
        this.onShoot = false;
        this.choose = true;
        this.bounty = 150;
        this.positionX;
        this.bitmap = gfx;
        this.assign_shoot = function () {
            window.setTimeout(function () { this.onShoot = true; }, 90000);
        }
        this.assign_health = function () {
            this.health = this.damage * this.resource;
        }
        /*this.shooting = function () {
            onShoot = true;
        }*/
    }

    function Ship(gfx) {
        this.resource = 100;
        this.rate_fire;
        this.damage;
        this.range = 500;
        this.mobility;
        this.health;
        this.elusiveness;
        this.onShoot = false;
        this.choose = true;
        this.bounty = 100;
        this.positionX;
        this.bitmap = gfx;
        this.assign_shoot = function () {
            window.setTimeout(function () { this.onShoot = true; }, 75000);
        }
        this.assign_health = function () {
            this.health = this.damage * this.resource;
        }
        /*this.shooting = function () {
            onShoot = true;
        }*/
    }

    function GreatBase() {
        this.level = 1;
        this.cost = 5000;
        this.produce = false;
        this.timeout;
        this.produceUnit = function () {
            this.timeout = window.setTimeout(function () { greatBase.produce = true; }, 2000);
        }
        this.produce_permis = function () {
            if (this.produce) this.produce = false;
            else {
                this.produce = true;
            }
        }
        this.upgrade = function () {
            if (player.point >= this.cost) {
                cost = cost * 2;
                this.level += 1;
                if (this.level == 5) {
                    tankImage = preloadQ.getResult("Tank");
                    Tank = new Tank(new createjs.Bitmap(tankImage));
                    unit[1] = Tank;
                    position = memposition[1].split(",");
                    unit[1].bitmap.x = position[0];
                    unit[1].bitmap.y = position[1];
                    unit[1].positionX = 303;
                    gameStage.addChild(unit[1]);

                    tankEnemyImage = preloadQ.getResult("Tank");
                    tankEnemy = new Tank(new createjs.Bitmap(tankEnemyImage));
                    unitEnemy[1] = tankEnemy;
                    position = mempositionEnemy[1].split(",");
                    unitEnemy[1].bitmap.x = position[0];
                    unitEnemy[1].bitmap.y = position[1];
                    unitEnemy[1].positionX = 991;
                    gameStage.addChild(unit[1]);
                }
                else if (this.level == 10) {
                    shipImage = preloadQ.getResult("ship");
                    ship = new Ship(new createjs.Bitmap(shipImage));
                    unit[2] = ship;
                    position = memposition[2].split(",");
                    unit[2].bitmap.x = position[0];
                    unit[2].bitmap.y = position[1];
                    unit[2].positionX = 303;
                    gameStage.addChild(unit[2]);

                    shipEnemyImage = preloadQ.getResult("ship");
                    shipEnemy = new Ship(new createjs.Bitmap(shipEnemyImage));
                    unitEnemy[2] = shipEnemy;
                    position = mempositionEnemy[2].split(",");
                    unitEnemy[2].bitmap.x = position[0];
                    unitEnemy[2].bitmap.y = position[1];
                    unitEnemy[2].positionX = 991;
                    gameStage.addChild(unit[2]);
                }
                else if (this.level == 15) {
                    airplanImage = preloadQ.getResult("airplan");
                    airplan = new Airplan(new createjs.Bitmap(airplanImage));
                    unit[3] = airplane;
                    position = memposition[3].split(",");
                    unit[3].bitmap.x = position[0];
                    unit[3].bitmap.y = position[1];
                    unit[3].positionX = 303;
                    gameStage.addChild(unit[3]);

                    airplanEnemyImage = preloadQ.getResult("airplan");
                    airplanEnemy = new Airplan(new createjs.Bitmap(airplanEnemyImage));
                    unitEnemy[3] = airplanEnemy;
                    position = mempositionEnemy[3].split(",");
                    unitEnemy[3].bitmap.x = position[0];
                    unitEnemy[3].bitmap.y = position[1];
                    unitEnemy[3].positionX = 991;
                    gameStage.addChild(unit[3]);
                }

            }
        }
    }


    function initialize() {
        canvas = document.getElementById("cv");
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;
        context = canvas.getContext("2d");
        gameStage = new createjs.Stage(canvas);

        canvas.addEventListener("MSPointerUp", pointerUp, false);
        //canvas.addEventListener("MSPointerMove", clicked);
        cv.addEventListener("click", click, false);
        loadContent();

    }

    function clicked(e) {
       
    }

    function loadContent() {
        preloadQ = new createjs.LoadQueue();  
        preloadQ.on("complete", prepareStage, this);  

        preloadQ.loadManifest([  
            { id: "logoScreen", src: "images/logoScreen.png" },
            { id: "background", src: "images/background.png" },
            { id: "ship", src: "images/ship.png" },
            { id: "Tankbattle", src: "images/tank.png" },
            { id: "helicopter", src: "images/helicopter.png" },
            { id: "airplan", src: "images/airplan.png" },
            { id: "startbt_1", src: "images/buttom1.png" },
            { id: "startbt_2", src: "images/buttom2.png" },
             { id: "bgitem", src: "images/GFX/BGitem4png.png" },
             { id: "H", src: "images/GFX/H.png" },
             { id: "hight_M_vehicle", src: "images\GFX\High Mobility Multipurpose Wheeled Vehicle.png" },
             { id: "light_tank", src: "images/GFX/light tank.png" },
             { id: "soldier", src: "images/GFX/soldier.png" },
             { id: "submarine", src: "images/GFX/submarine.png" },
             { id: "tank", src: "images/GFX/tank.png" },
             { id: "fighter", src: "images/GFX/fighter.png" },
             { id: "bomber", src: "images/GFX/bomber.png" },
             { id: "light_armo", src: "images/GFX/Avenger.png" },
             { id: "assault_ship", src: "images/GFX/assault ship.png" },
             { id: "aircraft_carrier", src: "images/GFX/aircraft carrier.png" },
             { id: "anti_air_tank", src: "images/GFX/ADATS.png" }
        ]);

    }

    function prepareStage() {


        logoScreenImage = preloadQ.getResult("logoScreen");
        logoScreenBitmap = new createjs.Bitmap(logoScreenImage);  
        logoScreenBitmap.scaleX = scaleX;
        logoScreenBitmap.scaleY = scaleY;
        gameStage.addChild(logoScreenBitmap);

        backgroundImage = preloadQ.getResult("background");
        backgroundBitmap = new createjs.Bitmap(backgroundImage);  
        backgroundBitmap.x = window.innerWidth / 2 - backgroundBitmap.image.width / 2;
        backgroundBitmap.y = window.innerHeight / 2 - backgroundBitmap.image.height / 2;
        gameStage.addChild(backgroundBitmap);

        startbt_1Image = preloadQ.getResult("startbt_1");
        startbt_1Bitmap = new createjs.Bitmap(startbt_1Image);  
        startbt_1Bitmap.x = 127;
        startbt_1Bitmap.y = 581;
        gameStage.addChild(startbt_1Bitmap);


        var y, x, xEnemy, j, k;
        //assign position in table
        for (j = 0; j < 2; j++) {
            if (j == 0) {
                x = 232; y = 125;
                xEnemy = 1061;
                for (k = 0; k < 8; k++) {
                    memposition[k] = x + "," + y;
                    mempositionEnemy[k] = xEnemy + "," + y;
                    y += 54;
                }
            }
            else {
                x = 158; y = 125;
                xEnemy = 1136;
                for (k = 8; k < 16; k++) {
                    memposition[k] = x + "," + y;
                    mempositionEnemy[k] = xEnemy + "," + y;
                    y += 54;
                }
            }
        }

        //assign position in battle
        x = 303; y = 179; xEnemy = 991;
        for (j = 0; j < 6; j++) {
            memPositionBattle[j] = x + "," + y;
            memPositionEnemyBattle[j] = xEnemy + "," + y;
            y += 54;
        }

        soldierImage = preloadQ.getResult("helicopter");
        soldier = new Soldier(new createjs.Bitmap(soldierImage));
        unit[0] = soldier;
        position = memposition[0].split(",");
        unit[0].bitmap.x = position[0];
        unit[0].bitmap.y = position[1];
        unit[0].positionX = 303;
        gameStage.addChild(unit[0].bitmap);

        tankImage = preloadQ.getResult("Tankbattle");
        Tankbattle = new Tank(new createjs.Bitmap(tankImage));
        unit[1] = Tankbattle;
        position = memposition[1].split(",");
        unit[1].bitmap.x = position[0];
        unit[1].bitmap.y = position[1];
        unit[1].positionX = 303;
        gameStage.addChild(unit[1].bitmap);

        soldierEnemyImage = preloadQ.getResult("helicopter");
        soldierEnemy = new Soldier(new createjs.Bitmap(soldierEnemyImage));
        unitEnemy[0] = soldierEnemy;
        position = mempositionEnemy[0].split(",");
        unitEnemy[0].bitmap.x = position[0];
        unitEnemy[0].bitmap.y = position[1];
        unitEnemy[0].positionX = 991;
        gameStage.addChild(unitEnemy[0].bitmap);

        tankEnemyImage = preloadQ.getResult("Tankbattle");
        tankEnemy = new Tank(new createjs.Bitmap(tankEnemyImage));
        unitEnemy[1] = tankEnemy;
        position = mempositionEnemy[1].split(",");
        unitEnemy[1].bitmap.x = position[0];
        unitEnemy[1].bitmap.y = position[1];
        unitEnemy[1].positionX = 991;
        gameStage.addChild(unitEnemy[1].bitmap);

        greatBase = new GreatBase();

        timeText = new createjs.Text(min + " : " + sec, "30px sans-serif", "red");
        timeText.x = window.innerWidth / 2 - timeText.getMeasuredWidth() / 2;
        timeText.y = 125;
        gameStage.addChild(timeText);
        timeText.visible = false;

        statusText = new createjs.Text(msg, "40px sans-serif", "red");
        statusText.x = window.innerWidth / 2 - statusText.getMeasuredWidth() / 2;
        statusText.y = 616;
        gameStage.addChild(statusText);
        statusText.visible = false;

        pointText = new createjs.Text("Points : " + player.point, "20px sans-serif", "red");
        pointText.x = 1052;
        pointText.y = 80;
        gameStage.addChild(pointText);
        pointText.visible = false;



        bgshopimage = preloadQ.getResult("bgitem");
        bgshopbitmap = new createjs.Bitmap(bgshopimage);
        bgshopbitmap.scaleX = window.innerWidth / 1366;
        bgshopbitmap.scaleY = window.innerHeight / 768;
        bgshopbitmap.visible = false;
        gameStage.addChild(bgshopbitmap);

        H.image = preloadQ.getResult("H");
        H.bitmap = new createjs.Bitmap(H.image);
        H.bitmap.x = Px;
        H.bitmap.y = Py;
        H.bitmap.visible = false;
        gameStage.addChild(H.bitmap);
        gameStage.addChild(H.price);

        aircraft_carrier.image = preloadQ.getResult("aircraft_carrier");
        aircraft_carrier.bitmap = new createjs.Bitmap(aircraft_carrier.image);
        aircraft_carrier.bitmap.x = Px;
        aircraft_carrier.bitmap.y = Py;
        aircraft_carrier.bitmap.visible = false;
        gameStage.addChild(aircraft_carrier.bitmap);
        gameStage.addChild(aircraft_carrier.price);

        assault_ship.image = preloadQ.getResult("assault_ship");
        assault_ship.bitmap = new createjs.Bitmap(assault_ship.image);
        assault_ship.bitmap.x = Px;
        assault_ship.bitmap.y = Py;
        assault_ship.bitmap.visible = false;
        gameStage.addChild(assault_ship.bitmap);
        gameStage.addChild(assault_ship.price);

        submarine.image = preloadQ.getResult("submarine");
        submarine.bitmap = new createjs.Bitmap(submarine.image);
        submarine.bitmap.x = Px;
        submarine.bitmap.y = Py;
        submarine.bitmap.visible = false;
        gameStage.addChild(submarine.bitmap);
        gameStage.addChild(submarine.price);

        tank.image = preloadQ.getResult("tank");
        tank.bitmap = new createjs.Bitmap(tank.image);
        tank.bitmap.x = Px;
        tank.bitmap.y = Py;
        tank.bitmap.visible = false;
        gameStage.addChild(tank.bitmap);
        gameStage.addChild(tank.price);

        light_tank.image = preloadQ.getResult("light_tank");
        light_tank.bitmap = new createjs.Bitmap(light_tank.image);
        light_tank.bitmap.x = Px;
        light_tank.bitmap.y = Py;
        light_tank.bitmap.visible = false;
        gameStage.addChild(light_tank.bitmap);
        gameStage.addChild(light_tank.price);

        light_armo.image = preloadQ.getResult("light_armo");
        light_armo.bitmap = new createjs.Bitmap(light_armo.image);
        light_armo.bitmap.x = Px;
        light_armo.bitmap.y = Py;
        light_armo.bitmap.visible = false;
        gameStage.addChild(light_armo.bitmap);
        gameStage.addChild(light_armo.price);

        hight_M_vehicle.image = preloadQ.getResult("hight_M_vehicle");
        hight_M_vehicle.bitmap = new createjs.Bitmap(hight_M_vehicle.image);
        hight_M_vehicle.bitmap.x = Px;
        hight_M_vehicle.bitmap.y = Py;
        hight_M_vehicle.bitmap.visible = false;
        gameStage.addChild(hight_M_vehicle.bitmap);
        gameStage.addChild(hight_M_vehicle.price);

        soilder.image = preloadQ.getResult("soldier");
        soilder.bitmap = new createjs.Bitmap(soilder.image);
        soilder.bitmap.x = Px;
        soilder.bitmap.y = Py;
        soilder.bitmap.visible = false;
        gameStage.addChild(soilder.bitmap);
        gameStage.addChild(soilder.price);

        anti_aircraft_tank.image = preloadQ.getResult("anti_air_tank");
        anti_aircraft_tank.bitmap = new createjs.Bitmap(anti_aircraft_tank.image);
        anti_aircraft_tank.bitmap.x = Px;
        anti_aircraft_tank.bitmap.y = Py;
        anti_aircraft_tank.bitmap.visible = false;
        gameStage.addChild(anti_aircraft_tank.bitmap);
        gameStage.addChild(anti_aircraft_tank.price);

        bomber_aircraft.image = preloadQ.getResult("bomber");
        bomber_aircraft.bitmap = new createjs.Bitmap(bomber_aircraft.image);
        bomber_aircraft.bitmap.x = Px;
        bomber_aircraft.bitmap.y = Py;
        bomber_aircraft.bitmap.visible = false;
        gameStage.addChild(bomber_aircraft.bitmap);
        gameStage.addChild(bomber_aircraft.price);

        fighter.image = preloadQ.getResult("fighter");
        fighter.bitmap = new createjs.Bitmap(fighter.image);
        fighter.bitmap.x = Px;
        fighter.bitmap.y = Py;
        fighter.bitmap.visible = false;
        gameStage.addChild(fighter.bitmap);
        gameStage.addChild(fighter.price);



        fighter.score = new createjs.Text(fighter.amongUnit, "10px sans-serif", "white");
        fighter.score.x = 125;
        fighter.score.y = 185;
        fighter.score.visible = true;
        gameStage.addChild(fighter.score);

        H.score = new createjs.Text(H.amongUnit, "10px sans-serif", "white");
        H.score.x = 315;
        H.score.y = 185;
        H.score.visible = true;
        gameStage.addChild(H.score);

        aircraft_carrier.score = new createjs.Text(aircraft_carrier.amongUnit, "10px sans-serif", "white");
        aircraft_carrier.score.x = 125;
        aircraft_carrier.score.y = 250;
        aircraft_carrier.score.visible = true;
        gameStage.addChild(aircraft_carrier.score);

        tank.score = new createjs.Text(tank.amongUnit, "10px sans-serif", "white");
        tank.score.x = 125;
        tank.score.y = 495;
        tank.score.visible = true;
        gameStage.addChild(tank.score);

        light_armo.score = new createjs.Text(light_armo.amongUnit, "10px sans-serif", "white");
        light_armo.score.x = 315;
        light_armo.score.y = 435;
        light_armo.score.visible = true;
        gameStage.addChild(light_armo.score);

        hight_M_vehicle.score = new createjs.Text(hight_M_vehicle.amongUnit, "10px sans-serif", "white");
        hight_M_vehicle.score.x = 125;
        hight_M_vehicle.score.y = 435;
        hight_M_vehicle.score.visible = true;
        gameStage.addChild(hight_M_vehicle.score);

        light_tank.score = new createjs.Text(light_tank.amongUnit, "10px sans-serif", "white");
        light_tank.score.x = 315;
        light_tank.score.y = 370;
        light_tank.score.visible = true;
        gameStage.addChild(light_tank.score);

        anti_aircraft_tank.score = new createjs.Text(anti_aircraft_tank.amongUnit, "10px sans-serif", "white");
        anti_aircraft_tank.score.x = 125;
        anti_aircraft_tank.score.y = 370;
        anti_aircraft_tank.score.visible = true;
        gameStage.addChild(anti_aircraft_tank.score);

        bomber_aircraft.score = new createjs.Text(bomber_aircraft.amongUnit, "10px sans-serif", "white");
        bomber_aircraft.score.x = 315;
        bomber_aircraft.score.y = 310;
        bomber_aircraft.score.visible = true;
        gameStage.addChild(bomber_aircraft.score);

        submarine.score = new createjs.Text(submarine.amongUnit, "10px sans-serif", "white");
        submarine.score.x = 125;
        submarine.score.y = 315;
        submarine.score.visible = true;
        gameStage.addChild(submarine.score);

        soilder.score = new createjs.Text(soilder.amongUnit, "10px sans-serif", "white");
        soilder.score.x = 315;
        soilder.score.y = 495;
        soilder.score.visible = true;
        gameStage.addChild(soilder.score);

        assault_ship.score = new createjs.Text(assault_ship.amongUnit, "10px sans-serif", "white");
        assault_ship.score.x = 315;
        assault_ship.score.y = 250;
        assault_ship.score.visible = true;
        gameStage.addChild(assault_ship.score);

        player.ricescore = new createjs.Text(player.rice, "20px sans-serif", "white");
        player.ricescore.x = 567;
        player.ricescore.y = 325;
        player.ricescore.visible = true;
        gameStage.addChild(player.ricescore);

        player.goldscore = new createjs.Text(player.gold, "20px sans-serif", "white");
        player.goldscore.x = 567;
        player.goldscore.y = 160;
        player.goldscore.visible = true;
        gameStage.addChild(player.goldscore);


        player.oilscore = new createjs.Text(player.oil, "20px sans-serif", "white");
        player.oilscore.x = 567;
        player.oilscore.y = 410;
        player.oilscore.visible = true;
        gameStage.addChild(player.oilscore);


        player.ironscore = new createjs.Text(player.iron, "20px sans-serif", "white");
        player.ironscore.x = 567;
        player.ironscore.y = 238;
        player.ironscore.visible = true;
        gameStage.addChild(player.ironscore);


        Myaircraft();
        Myvehicle();
        Myship();
        Mysoldier();

        createjs.Ticker.setInterval(window.requestAnimationFrame);
        createjs.Ticker.addEventListener("tick", gameLoop);
    }

    function gameLoop() {
        update();
        draw();
    }

    function setShop() {
        fighter.score.visible = true;
        H.score.visible = true;
        aircraft_carrier.score.visible = true;
        tank.score.visible = true;
        light_armo.score.visible = true;
        hight_M_vehicle.score.visible = true;
        light_tank.score.visible = true;
        anti_aircraft_tank.score.visible = true;
        bomber_aircraft.score.visible = true;
        submarine.score.visible = true;
        soilder.score.visible = true;
        assault_ship.score.visible = true;

        logoScreenBitmap.visible = false;
        bgshopbitmap.visible = true;
        fighter.score.text = fighter.amongUnit;
        H.score.text = H.amongUnit;
        aircraft_carrier.score.text = aircraft_carrier.amongUnit;
        tank.score.text = tank.amongUnit;
        light_armo.score.text = light_armo.amongUnit;
        hight_M_vehicle.score.text = hight_M_vehicle.amongUnit;
        anti_aircraft_tank.score.text = anti_aircraft_tank.amongUnit;
        bomber_aircraft.score.text = bomber_aircraft.amongUnit;
        submarine.score.text = submarine.amongUnit;
        soilder.score.text = soilder.amongUnit;
        assault_ship.score.text = assault_ship.amongUnit;
        light_tank.score.text = light_tank.amongUnit;
        if (ourAir) {
            figheramong.text = player.fighter;
            helamong.text = player.H;
            figheramong.visible = true;
            fighterbitmap.visible = true;
            helamong.visible = true;
            helbitmap.visible = true;
            mytankbitmap.visible = false;
            mytankamong.visible = false;
            mylight_tankamong.visible = false;
            mylight_tankbitmap.visible = false;
            mylight_armobitmap.visible = false;
            mylight_armoamong.visible = false;
            myanti_aircraftbitmap.visible = false;
            myanti_aircraftamong.visible = false;
            myaircraft_carrierbitmap.visible = false;
            myaircraft_carrieramong.visible = false;
            myassault_shipbitmap.visible = false;
            myairassault_shipamong.visible = false;
            mysoldierbitmap.visible = false;
            mysoldieramong.visible = false;
        }
        if (ourbattleship) {
            myaircraft_carrieramong.text = player.aircraft_carrier;
            myairassault_shipamong.text = player.assault_ship;
            myaircraft_carrierbitmap.visible = true;
            myaircraft_carrieramong.visible = true;
            myassault_shipbitmap.visible = true;
            myairassault_shipamong.visible = true;
            figheramong.visible = false;
            fighterbitmap.visible = false;
            helamong.visible = false;
            helbitmap.visible = false;
            mytankbitmap.visible = false;
            mytankamong.visible = false;
            mylight_tankamong.visible = false;
            mylight_tankbitmap.visible = false;
            mylight_armobitmap.visible = false;
            mylight_armoamong.visible = false;
            myanti_aircraftbitmap.visible = false;
            myanti_aircraftamong.visible = false;
            mysoldierbitmap.visible = false;
            mysoldieramong.visible = false;
        }
        if (oursoldier) {
            mysoldieramong.text = player.soilder;
            figheramong.visible = false;
            fighterbitmap.visible = false;
            helamong.visible = false;
            helbitmap.visible = false;
            myaircraft_carrierbitmap.visible = false;
            myaircraft_carrieramong.visible = false;
            myassault_shipbitmap.visible = false;
            myairassault_shipamong.visible = false;
            mysoldierbitmap.visible = true;
            mysoldieramong.visible = true;
        }
        if (ourvehicle) {

            mytankamong.text = player.tank;
            mylight_tankamong.text = player.light_tank;
            mylight_armoamong.text = player.light_armo;
            myanti_aircraftamong.text = player.anti_aircraft_tank;

            mytankbitmap.visible = true;
            mytankamong.visible = true;

            mylight_tankamong.visible = true;
            mylight_tankbitmap.visible = true;

            mylight_armobitmap.visible = true;
            mylight_armoamong.visible = true;

            myanti_aircraftbitmap.visible = true;
            myanti_aircraftamong.visible = true;

            figheramong.visible = false;
            fighterbitmap.visible = false;

            helamong.visible = false;
            helbitmap.visible = false;
            myaircraft_carrierbitmap.visible = false;
            myaircraft_carrieramong.visible = false;

            myassault_shipbitmap.visible = false;
            myairassault_shipamong.visible = false;

            mytankbitmap.visible = true;
            mytankamong.visible = true;

            mylight_tankamong.visible = true;
            mylight_tankbitmap.visible = true;

            mylight_armobitmap.visible = true;
            mylight_armoamong.visible = true;

            myanti_aircraftbitmap.visible = true;
            myanti_aircraftamong.visible = true;

            mysoldierbitmap.visible = false;
            mysoldieramong.visible = false;



        }
        player.ironscore.text = player.iron;
        player.goldscore.text = player.gold;
        player.oilscore.text = player.oil;
        player.ricescore.text = player.rice;

        player.ironscore.visible = true;
        player.goldscore.visible = true;
        player.oilscore.visible = true;
        player.ricescore.visible = true;
    }
    
    function update() {
        if (newGame) {
            logoScreenBitmap.visible = true;
            backgroundBitmap.visible = false;
            startbt_1Bitmap.visible = false;
            clear();
            for (var i = 0; i < unit.length; i++) unit[i].bitmap.visible = false;
            for (var i = 0; i < unitEnemy.length; i++) unitEnemy[i].bitmap.visible = false;
            
        }
        else if(battlefield){
            logoScreenBitmap.visible = false;
            backgroundBitmap.visible = true;
            startbt_1Bitmap.visible = true;
            pointText.visible = true;
            pointText.text = ("Points : " + player.point);
            for (var i = 0; i < unit.length; i++) unit[i].bitmap.visible = true;
            for (var i = 0; i < unitEnemy.length; i++) unitEnemy[i].bitmap.visible = true;
            if (battle && isEnemy()) {
                time();
                isCollision();
                isRange();
                if (!isEnemy()) {
                    for (var i = 0; i < unit.length; i++) {
                        position = memposition[i].split(",");
                        unit[i].bitmap.x = position[0];
                        unit[i].bitmap.y = position[1];
                        unit[i].choose = true;
                        unit[i].positionX = 303;
                        unit[i].resource = Math.ceil(unit[i].health / unit[i].damage);
                        gameStage.removeChild(unit[i].healthText);
                    }
                    for (var i = 0; i < unitEnemy.length; i++) {
                        position = mempositionEnemy[i].split(",");
                        unitEnemy[i].bitmap.x = position[0];
                        unitEnemy[i].bitmap.y = position[1];
                        unitEnemy[i].choose = true;
                        unitEnemy[i].positionX = 991;
                        unitEnemy[i].resource = Math.ceil(unitEnemy[i].health / unitEnemy[i].damage);
                        gameStage.removeChild(unitEnemy[i].healthText);
                    }
                    Battle.splice(0, Battle.length);
                    BattleEnemy.splice(0, BattleEnemy.length);
                    battle = false;
                    count_click = 0;
                    greatBase.produceUnit();
                    timeText.visible = false;
                    min = 0; sec = 0; timeCount = 0;
                }
            }
            else
                manufacturing_base();
        }
        else if (shop) {
            setShop();
        }
    }

    function draw() {
        gameStage.update();
    }

    function manufacturing_base() {
        if (greatBase.produce) {

            for (var i = 0; i < unit.length; i++) {
                if (i == 0) {
                    unit[i].resource += 10 * greatBase.level;
                    unitEnemy[i].resource += 10 * greatBase.level * 1.6;
                }
                else if (i == 1) {
                    unit[i].resource += 5 * greatBase.level;
                    unitEnemy[i].resource += 5 * greatBase.level * 1.6;
                }
                else if (i == 2) {
                    unit[i].resource += 3 * greatBase.level;
                    unitEnemy[i].resource += 3 * greatBase.level * 1.6;
                }
                else if (i == 3) {
                    unit[i].resource += 2 * greatBase.level;
                    unitEnemy[i].resource += 2 * greatBase.level * 1.6;
                }
            }

            greatBase.produce = false;
            greatBase.produceUnit();
        }
    }

    function isEnemy() {
        var enemy = true;
        if (min == 1 && sec == 30) {
            showMessage("Time's Up");
            return false;
        }
        if (Battle.length == 0 || BattleEnemy.length == 0) {
            if (Battle.length == 0) showMessage("You Lost");
            else showMessage("You Win");
            return false;
        }
        return enemy;
    }

    function isRange() {
        var rangeShoot;

        for (var i = 0; i < Battle.length; i++)
            for (var j = 0; j < BattleEnemy.length; j++) {
                rangeShoot = Math.abs((Battle[i].bitmap.x + 60) - (BattleEnemy[j].bitmap.x));
                if (rangeShoot <= Battle[i].range) {
                    if (Battle[i].onShoot && Battle[i].health >= 0.1 && BattleEnemy[j].health >= 0.1) {
                        numShoot = BattleEnemy[j].shooting(Battle[i]);
                        if (BattleEnemy[j].health - numShoot >= 0.1) {
                            BattleEnemy[j].health -= numShoot;
                            BattleEnemy[j].resource = Math.ceil(BattleEnemy[j].health);
                            player.point += Math.floor(numShoot * BattleEnemy[j].bounty);
                        }
                        else {
                            player.point += Math.floor(BattleEnemy[j].health * BattleEnemy[j].bounty);
                            BattleEnemy[j].resource = 0;
                            BattleEnemy[j].health = 0;
                            removeEnemy.push(j);
                        }
                        Battle[i].onShoot = false;
                        Battle[i].assign_shoot(Battle[i]);

                    }
                }
                if (rangeShoot <= BattleEnemy[j].range) {
                    if (BattleEnemy[j].onShoot && BattleEnemy[j].health >= 0.1 && Battle[i].health >= 0.1) {
                        numShoot = Battle[i].shooting(BattleEnemy[j]);
                        if (Battle[i].health - numShoot >= 0.1) {
                            Battle[i].resource = Math.ceil(Battle[i].health);
                            Battle[i].health -= numShoot;
                        }
                        else {
                            Battle[i].resource = 0;
                            Battle[i].health = 0;
                            remove.push(i);
                        }
                        BattleEnemy[j].onShoot = false;
                        BattleEnemy[j].assign_shoot(BattleEnemy[j]);
                    }
                }
                Battle[i].healthText.text = (Battle[i].health.toFixed(0));
                BattleEnemy[j].healthText.text = (BattleEnemy[j].health.toFixed(0));
            }
        for (var i = 0; i < remove.length; i++) Battle.splice(remove.pop(), 1);
        for (var i = 0; i < removeEnemy.length; i++) BattleEnemy.splice(removeEnemy.pop(), 1);
    }

    function isCollision() {
        var colision;

        for (var i = 0; i < Battle.length; i++) {
            colision = true;
            for (var j = 0; j < BattleEnemy.length; j++)
                if (Battle[i].bitmap.x + 60 >= BattleEnemy[j].bitmap.x)
                    colision = false;
            if (colision) {
                Battle[i].positionX += Battle[i].mobility;
                Battle[i].bitmap.x = Battle[i].positionX;
                Battle[i].healthText.x = Battle[i].bitmap.x;
            }
        }

        for (var i = 0; i < BattleEnemy.length; i++) {
            colision = true;
            for (var j = 0; j < Battle.length; j++)
                if (BattleEnemy[i].bitmap.x <= Battle[j].bitmap.x + 60)
                    colision = false;
            if (colision) {
                BattleEnemy[i].positionX -= BattleEnemy[i].mobility;
                BattleEnemy[i].bitmap.x = BattleEnemy[i].positionX;
                BattleEnemy[i].healthText.x = BattleEnemy[i].bitmap.x;
            }
        }
    }

    function time() {
        timeCount += 1;
        if (timeCount == 60) {
            sec += 1;
            timeCount = 0;
        }
        if (sec == 60) {
            min += 1;
            sec = 0;
        }
        if (sec < 10) timeText.text = ("0" + min + " : 0" + sec);
        else timeText.text = ("0" + min + " : " + sec);
    }

    function showMessage(m) {
        msg = m;
        statusText.visible = true;
        statusText.text = (msg);
        setTimeout(function () { statusText.visible = false; }, 3000);
    }

    ////////////////////////////////////////////////
    function pointerUp(event) {
        if (newGame) {
            newGame = false;
            shop = true;
        }
        else if(battlefield){
            if (!battle) {
                if (Battle.length != 0)
                    if (event.pageX >= 127 && event.pageX <= 278)
                        if (event.pageY >= 582 && event.pageY <= 699) {
                            battle = true;
                            for (var i = 0; i < Battle.length; i++) {
                                clearTimeout(Battle[i].myshoot);
                                Battle[i].assign_shoot(Battle[i]);
                                Battle[i].assign_health();
                            }
                            for (var i = 0; i < unitEnemy.length; i++) {
                                inBattleEnemy(Math.floor(Math.random() * 20) % 10, i);
                                if (i == 5) break;
                            }
                            for (var i = 0; i < BattleEnemy.length; i++) {
                                clearTimeout(BattleEnemy[i].myshoot);
                                BattleEnemy[i].assign_shoot(BattleEnemy[i]);
                                BattleEnemy[i].assign_health();
                            }
                            clearTimeout(greatBase.timeout);
                            timeText.visible = true;
                        }
                if (event.pageX >= 1081 && event.pageX <= 1232)
                    if (event.pageY >= 582 && event.pageY <= 699) {
                        shop = true;
                        battlefield = false;
                        //greatBase.upgrade;
                    }
                if (Battle.length <= 6) { inBattle(event); }
            }
        }
    }

    function inBattle(event) {
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 125 && event.pageY <= 172)
                if (unit[0] != null) {
                    if (unit[0].choose) {
                        unit[0].choose = false;
                        Battle[count_click] = unit[0];
                        position = memPositionBattle[count_click].split(",");
                        unit[0].bitmap.x = position[0];
                        unit[0].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 179 && event.pageY <= 226)
                if (unit[1] != null) {
                    if (unit[1].choose) {
                        unit[1].choose = false;
                        Battle[count_click] = unit[1];
                        position = memPositionBattle[count_click].split(",");
                        unit[1].bitmap.x = position[0];
                        unit[1].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 233 && event.pageY <= 280)
                if (unit[2] != null) {
                    if (unit[2].choose) {
                        unit[2].choose = false;
                        Battle[count_click] = unit[2];
                        position = memPositionBattle[count_click].split(",");
                        unit[2].bitmap.x = position[0];
                        unit[2].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 287 && event.pageY <= 334)
                if (unit[3] != null) {
                    if (unit[3].choose) {
                        unit[3].choose = false;
                        Battle[count_click] = unit[3];
                        position = memPositionBattle[count_click].split(",");
                        unit[3].bitmap.x = position[0];
                        unit[3].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 341 && event.pageY <= 388)
                if (unit[4] != null) {
                    if (unit[4].choose) {
                        unit[4].choose = false;
                        Battle[count_click] = unit[4];
                        position = memPositionBattle[count_click].split(",");
                        unit[4].bitmap.x = position[0];
                        unit[4].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 395 && event.pageY <= 442)
                if (unit[5] != null) {
                    if (unit[5].choose) {
                        unit[5].choose = false;
                        Battle[count_click] = unit[5];
                        position = memPositionBattle[count_click].split(",");
                        unit[5].bitmap.x = position[0];
                        unit[5].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 449 && event.pageY <= 496)
                if (unit[6] != null) {
                    if (unit[6].choose) {
                        unit[6].choose = false;
                        Battle[count_click] = unit[6];
                        position = memPositionBattle[count_click].split(",");
                        unit[6].bitmap.x = position[0];
                        unit[6].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 232 && event.pageX <= 292) {
            if (event.pageY >= 503 && event.pageY <= 550)
                if (unit[7] != null) {
                    if (unit[7].choose) {
                        unit[7].choose = false;
                        Battle[count_click] = unit[7];
                        position = memPositionBattle[count_click].split(",");
                        unit[7].bitmap.x = position[0];
                        unit[7].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 125 && event.pageY <= 172)
                if (unit[8] != null) {
                    if (unit[8].choose) {
                        unit[8].choose = false;
                        Battle[count_click] = unit[8];
                        position = memPositionBattle[count_click].split(",");
                        unit[8].bitmap.x = position[0];
                        unit[8].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 179 && event.pageY <= 226)
                if (unit[9] != null) {
                    if (unit[9].choose) {
                        unit[9].choose = false;
                        Battle[count_click] = unit[9];
                        position = memPositionBattle[count_click].split(",");
                        unit[9].bitmap.x = position[0];
                        unit[9].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 233 && event.pageY <= 280)
                if (unit[10] != null) {
                    if (unit[10].choose) {
                        unit[10].choose = false;
                        Battle[count_click] = unit[10];
                        position = memPositionBattle[count_click].split(",");
                        unit[10].bitmap.x = position[0];
                        unit[10].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 287 && event.pageY <= 334)
                if (unit[11] != null) {
                    if (unit[11].choose) {
                        unit[11].choose = false;
                        Battle[count_click] = unit[11];
                        position = memPositionBattle[count_click].split(",");
                        unit[11].bitmap.x = position[0];
                        unit[11].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 341 && event.pageY <= 388)
                if (unit[12] != null) {
                    if (unit[12].choose) {
                        unit[12].choose = false;
                        Battle[count_click] = unit[12];
                        position = memPositionBattle[count_click].split(",");
                        unit[12].bitmap.x = position[0];
                        unit[12].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 395 && event.pageY <= 442)
                if (unit[13] != null) {
                    if (unit[13].choose) {
                        unit[13].choose = false;
                        Battle[count_click] = unit[13];
                        position = memPositionBattle[count_click].split(",");
                        unit[13].bitmap.x = position[0];
                        unit[13].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 449 && event.pageY <= 496)
                if (unit[14] != null) {
                    if (unit[14].choose) {
                        unit[14].choose = false;
                        Battle[count_click] = unit[14];
                        position = memPositionBattle[count_click].split(",");
                        unit[14].bitmap.x = position[0];
                        unit[14].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }
        if (event.pageX >= 158 && event.pageX <= 218) {
            if (event.pageY >= 503 && event.pageY <= 550)
                if (unit[15] != null) {
                    if (unit[15].choose) {
                        unit[15].choose = false;
                        Battle[count_click] = unit[15];
                        position = memPositionBattle[count_click].split(",");
                        unit[15].bitmap.x = position[0];
                        unit[15].bitmap.y = position[1];
                        ++count_click;
                    }
                }
        }

    }

    function inBattleEnemy(rand, i) {
        if (rand == 0) {
            if (unitEnemy[0] != null && unitEnemy[0].choose) {
                unitEnemy[0].choose = false;
                BattleEnemy[i] = unitEnemy[0];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[0].bitmap.x = position[0];
                unitEnemy[0].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 1) {
            if (unitEnemy[1] != null && unitEnemy[1].choose) {
                unitEnemy[1].choose = false;
                BattleEnemy[i] = unitEnemy[1];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[1].bitmap.x = position[0];
                unitEnemy[1].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 2) {
            if (unitEnemy[2] != null && unitEnemy[2].choose) {
                unitEnemy[2].choose = false;
                BattleEnemy[i] = unitEnemy[2];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[2].bitmap.x = position[0];
                unitEnemy[2].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 3) {
            if (unitEnemy[3] != null && unitEnemy[3].choose) {
                unitEnemy[3].choose = false;
                BattleEnemy[i] = unitEnemy[3];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[3].bitmap.x = position[0];
                unitEnemy[3].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 4) {
            if (unitEnemy[4] != null && unitEnemy[4].choose) {
                unitEnemy[4].choose = false;
                BattleEnemy[i] = unit[4];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[4].bitmap.x = position[0];
                unitEnemy[4].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 5) {
            if (unitEnemy[5] != null && unitEnemy[5].choose) {
                unitEnemy[5].choose = false;
                BattleEnemy[i] = unitEnemy[5];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[5].bitmap.x = position[0];
                unitEnemy[5].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 6) {
            if (unitEnemy[6] != null && unitEnemy[6].choose) {
                unitEnemy[6].choose = false;
                BattleEnemy[i] = unitEnemy[6];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[6].bitmap.x = position[0];
                unitEnemy[6].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 7) {
            if (unitEnemy[7] != null && unitEnemy[7].choose) {
                unitEnemy[7].choose = false;
                BattleEnemy[i] = unitEnemy[7];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[7].bitmap.x = position[0];
                unitEnemy[7].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 8) {
            if (unitEnemy[8] != null && unitEnemy[8].choose) {
                unitEnemy[8].choose = false;
                BattleEnemy[i] = unitEnemy[8];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[8].bitmap.x = position[0];
                unitEnemy[8].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 9) {
            if (unitEnemy[9] != null && unitEnemy[9].choose) {
                unitEnemy[9].choose = false;
                BattleEnemy[i] = unitEnemy[9];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[9].bitmap.x = position[0];
                unitEnemy[9].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 10) {
            if (unitEnemy[10] != null && unitEnemy[10].choose) {
                unitEnemy[10].choose = false;
                BattleEnemy[i] = unitEnemy[10];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[10].bitmap.x = position[0];
                unitEnemy[10].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 11) {
            if (unitEnemy[11] != null && unitEnemy[11].choose) {
                unitEnemy[11].choose = false;
                BattleEnemy[i] = unitEnemy[11];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[11].bitmap.x = position[0];
                unitEnemy[11].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 12) {
            if (unitEnemy[12] != null && unitEnemy[12].choose) {
                unitEnemy[12].choose = false;
                BattleEnemy[i] = unitEnemy[12];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[12].bitmap.x = position[0];
                unitEnemy[12].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 13) {
            if (unitEnemy[13] != null && unitEnemy[13].choose) {
                unitEnemy[13].choose = false;
                BattleEnemy[i] = unitEnemy[13];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[13].bitmap.x = position[0];
                unitEnemy[13].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 14) {
            if (unitEnemy[14] != null && unitEnemy[14].choose) {
                unitEnemy[14].choose = false;
                BattleEnemy[i] = unitEnemy[14];
                position = memPositionEnemyBattle[i].split(",");
                unitEnemy[14].bitmap.x = position[0];
                unitEnemy[14].bitmap.y = position[1];
            }
            else rand++;
        }
        if (rand == 15) {
            if (unitEnemy[15] != null && unitEnemy[15].choose) {
                unitEnemy[15].choose = false;
                BattleEnemy[i] = unitEnemy[15];
                position = memPositionEnemyBattle[i].split(",");
                unit[15].bitmap.x = position[0];
                unit[15].bitmap.y = position[1];
            }
            else inBattleEnemy(0, i);
        }
    }

    function ShowDataUnit(bitmap, price) {
        if (showPic != null) {
            showPic.visible = false;
            showPrice.visible = false;
        }
        showPic = bitmap;
        showPrice = price;

        showPic.visible = true;
        showPrice.visible = true;
    }
    function fighter_aircraft() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 5000;
        this.rice = 1000;
        this.oil = 3000;
        this.gold = 250;

        this.bitmap = null;
        this.image = null;

        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);

        this.isPressUp = function (x, y) {
            if (x > 210 && x < 230 && y > 165 && y < 192) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 192 && y < 212) {
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function light_armo() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;

        this.bitmap = null;
        this.image = null;

        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 406 && x < 427 && y > 409 && y < 431) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 427 && y > 431 && y < 456) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function H() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;

        this.bitmap = null;
        this.image = null;

        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);

        this.isPressUp = function (x, y) {

            if (x > 406 && x < 427 && y > 166 && y < 190) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 427 && y > 190 && y < 215) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function aircraft_carrier() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 20000;
        this.rice = 10000;
        this.oil = 16000;
        this.gold = 4000;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 210 && x < 230 && y > 225 && y < 250) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 250 && y < 275) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function assault_ship() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 406 && x < 427 && y > 225 && y < 250) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 427 && y > 250 && y < 275) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function submarine() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {

            if (x > 210 && x < 230 && y > 286 && y < 311) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 311 && y < 336) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function bomber_aircraft() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {

            if (x > 406 && x < 427 && y > 286 && y < 311) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 427 && y > 311 && y < 336) {
                if (this.amongUnit > 0) {
                    ShowDataUnit(this.bitmap, this.price);
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function anti_aircraft_tank() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 210 && x < 230 && y > 346 && y < 371) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 371 && y < 396) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function light_tank() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 406 && x < 427 && y > 346 && y < 371) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 427 && y > 371 && y < 396) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function hight_M_vehicle() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 210 && x < 230 && y > 409 && y < 434) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 434 && y < 459) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function tank() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);
        this.isPressUp = function (x, y) {
            if (x > 210 && x < 230 && y > 470 && y < 505) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 210 && x < 230 && y > 505 && y < 530) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function soilder() {
        this.score = null;
        this.amongUnit = 0;
        this.iron = 3000;
        this.rice = 500;
        this.oil = 1000;
        this.gold = 100;
        this.bitmap = null;
        this.image = null;
        this.price = Addprice(this.iron, this.rice, this.oil, this.gold);

        this.isPressUp = function (x, y) {
            if (x > 406 && x < 426 && y > 470 && y < 505) {
                ShowDataUnit(this.bitmap, this.price);
                this.amongUnit += 10;
                player.iron -= this.iron;
                player.rice -= this.rice;
                player.oil -= this.oil;
                player.gold -= this.gold;
            }
        }
        this.isPressDown = function (x, y) {
            if (x > 406 && x < 426 && y > 505 && y < 530) {
                ShowDataUnit(this.bitmap, this.price);
                if (this.amongUnit > 0) {
                    this.amongUnit -= 10;
                    player.iron += this.iron;
                    player.rice += this.rice;
                    player.oil += this.oil;
                    player.gold += this.gold;
                }
            }
        }
    }
    function Addprice(iron, rice, oil, gold) {
        var temp = new createjs.Text("Iron : " + iron + "\nRice : " + rice + "\nOil : " + oil + "\ngold : " + gold, "30px sans-serif", "black");
        temp.x = 1070;
        temp.y = 84;
        temp.visible = false;
        return temp;
    }
    function select(PosX, PosY) {
        fighter.isPressUp(PosX, PosY);
        fighter.isPressDown(PosX, PosY);
        H.isPressUp(PosX, PosY);
        H.isPressDown(PosX, PosY);
        tank.isPressUp(PosX, PosY);
        tank.isPressDown(PosX, PosY);
        light_armo.isPressUp(PosX, PosY);
        light_armo.isPressDown(PosX, PosY);
        hight_M_vehicle.isPressUp(PosX, PosY);
        hight_M_vehicle.isPressDown(PosX, PosY);
        anti_aircraft_tank.isPressUp(PosX, PosY);
        anti_aircraft_tank.isPressDown(PosX, PosY);
        bomber_aircraft.isPressUp(PosX, PosY);
        bomber_aircraft.isPressDown(PosX, PosY);
        submarine.isPressUp(PosX, PosY);
        submarine.isPressDown(PosX, PosY);
        soilder.isPressUp(PosX, PosY);
        soilder.isPressDown(PosX, PosY);
        assault_ship.isPressUp(PosX, PosY);
        assault_ship.isPressDown(PosX, PosY);
        light_tank.isPressUp(PosX, PosY);
        light_tank.isPressDown(PosX, PosY);
        aircraft_carrier.isPressUp(PosX, PosY);
        aircraft_carrier.isPressDown(PosX, PosY);
    }

    var ourAir = false;
    var ourvehicle = false;
    var ourbattleship = false;
    var oursoldier = false;
    function click(e) {
        if (shop) {
            select(e.pageX, e.pageY);
            if (e.pageX > 793 && e.pageX < 882 && e.pageY > 286 && e.pageY < 325) {
                ourAir = true;
                ourvehicle = false;
                ourbattleship = false;
                oursoldier = false;
            }
            else if (e.pageX > 900 && e.pageX < 989 && e.pageY > 286 && e.pageY < 325) {
                ourAir = false;
                ourvehicle = true;
                ourbattleship = false;
                oursoldier = false;
            }
            else if (e.pageX > 1011 && e.pageX < 1100 && e.pageY > 286 && e.pageY < 325) {
                ourAir = false;
                ourvehicle = false;
                ourbattleship = true;
                oursoldier = false;
            }
            else if (e.pageX > 1125 && e.pageX < 1214 && e.pageY > 286 && e.pageY < 325) {
                ourAir = false;
                ourvehicle = false;
                ourbattleship = false;
                oursoldier = true;
            }
            if (e.pageX > 44 && e.pageX < 140 && e.pageY > 554 && e.pageY < 607) {
                buy();
            }
            if (e.pageX > 831 && e.pageX < 970 && e.pageY > 577 && e.pageY < 700) {
                battlefield = true;
                shop = false;
                clear();
            }
        }
    }
    function buy() {
        player.aircraft_carrier += aircraft_carrier.amongUnit;
        player.fighter += fighter.amongUnit;
        player.H += H.amongUnit
        player.assault_ship += assault_ship.amongUnit
        player.submarine += submarine.amongUnit;
        player.bomber_aircraft += bomber_aircraft.amongUnit;
        player.anti_aircraft_tank += anti_aircraft_tank.amongUnit;
        player.light_tank += light_tank.amongUnit;
        player.hight_M_vehicle += hight_M_vehicle.amongUnit;
        player.light_armo += light_armo.amongUnit;
        player.tank += tank.amongUnit;
        player.soilder += soilder.amongUnit;
        aircraft_carrier.amongUnit = 0;
        fighter.amongUnit = 0;
        H.amongUnit = 0;
        assault_ship.amongUnit = 0;
        submarine.amongUnit = 0;
        bomber_aircraft.amongUnit = 0;
        anti_aircraft_tank.amongUnit = 0;
        light_tank.amongUnit = 0;
        hight_M_vehicle.amongUnit = 0;
        light_armo.amongUnit = 0;
        tank.amongUnit = 0;
        soilder.amongUnit = 0;
    }

    function clear() {

        H.bitmap.visible = false;
        aircraft_carrier.bitmap.visible = false;
        assault_ship.bitmap.visible = false;
        submarine.bitmap.visible = false;
        tank.bitmap.visible = false;
        light_tank.bitmap.visible = false;
        light_armo.bitmap.visible = false;
        hight_M_vehicle.bitmap.visible = false;
        soilder.bitmap.visible = false;
        anti_aircraft_tank.bitmap.visible = false;
        bomber_aircraft.bitmap.visible = false;
        fighter.bitmap.visible = false;

        H.price.visible = false;
        aircraft_carrier.price.visible = false;
        assault_ship.price.visible = false;
        submarine.price.visible = false;
        tank.price.visible = false;
        light_tank.price.visible = false;
        light_armo.price.visible = false;
        hight_M_vehicle.price.visible = false;
        soilder.price.visible = false;
        anti_aircraft_tank.price.visible = false;
        bomber_aircraft.price.visible = false;
        fighter.price.visible = false;

        mytankbitmap.visible = false;
        mytankamong.visible = false;

        mylight_tankamong.visible = false;
        mylight_tankbitmap.visible = false;

        mylight_armobitmap.visible = false;
        mylight_armoamong.visible = false;

        myanti_aircraftbitmap.visible = false;
        myanti_aircraftamong.visible = false;

        figheramong.visible = false;
        fighterbitmap.visible = false;

        helamong.visible = false;
        helbitmap.visible = false;
        myaircraft_carrierbitmap.visible = false;
        myaircraft_carrieramong.visible = false;

        myassault_shipbitmap.visible = false;
        myairassault_shipamong.visible = false;

        mytankbitmap.visible = false;
        mytankamong.visible = false;

        mylight_tankamong.visible = false;
        mylight_tankbitmap.visible = false;

        mylight_armobitmap.visible = false;
        mylight_armoamong.visible = false;

        myanti_aircraftbitmap.visible = false;
        myanti_aircraftamong.visible = false;

        mysoldierbitmap.visible = false;
        mysoldieramong.visible = false;

        fighter.score.visible = false;
        H.score.visible = false;
        aircraft_carrier.score.visible = false;
        tank.score.visible = false;
        light_armo.score.visible = false;
        hight_M_vehicle.score.visible = false;
        light_tank.score.visible = false;
        anti_aircraft_tank.score.visible = false;
        bomber_aircraft.score.visible = false;
        submarine.score.visible = false;
        soilder.score.visible = false;
        assault_ship.score.visible = false;
        player.ricescore.visible = false;
        player.goldscore.visible = false;
        player.oilscore.visible = false;
        player.ironscore.visible = false;
        bgshopbitmap.visible = false;

        
        


    }

    function Myaircraft() {
        fighterbitmap = new createjs.Bitmap(fighter.image);
        fighterbitmap.x = 804;
        fighterbitmap.y = 360;
        fighterbitmap.scaleX = 0.3;
        fighterbitmap.scaleY = 0.3;
        fighterbitmap.visible = false;
        gameStage.addChild(fighterbitmap);

        figheramong = new createjs.Text(player.fighter, "30px sans-serif", "white");
        figheramong.x = 900;
        figheramong.y = 363;
        figheramong.visible = false;
        gameStage.addChild(figheramong);

        helbitmap = new createjs.Bitmap(H.image);
        helbitmap.x = 804;
        helbitmap.y = 422;
        helbitmap.scaleX = 0.3;
        helbitmap.scaleY = 0.3;
        helbitmap.visible = false;
        gameStage.addChild(helbitmap);

        helamong = new createjs.Text(player.H, "30px sans-serif", "white");
        helamong.x = 900;
        helamong.y = 432;
        helamong.visible = false;
        gameStage.addChild(helamong);
    }

    function Myvehicle() {
        mytankbitmap = new createjs.Bitmap(tank.image);
        mytankbitmap.x = 804;
        mytankbitmap.y = 360;
        mytankbitmap.scaleX = 0.3;
        mytankbitmap.scaleY = 0.3;
        mytankbitmap.visible = false;
        gameStage.addChild(mytankbitmap);

        mytankamong = new createjs.Text(player.tank, "30px sans-serif", "white");
        mytankamong.x = 900;
        mytankamong.y = 363;
        mytankamong.visible = false;
        gameStage.addChild(mytankamong);

        mylight_tankbitmap = new createjs.Bitmap(light_tank.image);
        mylight_tankbitmap.x = 804;
        mylight_tankbitmap.y = 422;
        mylight_tankbitmap.scaleX = 0.3;
        mylight_tankbitmap.scaleY = 0.3;
        mylight_tankbitmap.visible = false;
        gameStage.addChild(mylight_tankbitmap);

        mylight_tankamong = new createjs.Text(player.light_tank, "30px sans-serif", "white");
        mylight_tankamong.x = 900;
        mylight_tankamong.y = 432;
        mylight_tankamong.visible = false;
        gameStage.addChild(mylight_tankamong);


        myanti_aircraftbitmap = new createjs.Bitmap(anti_aircraft_tank.image);
        myanti_aircraftbitmap.x = 1030;
        myanti_aircraftbitmap.y = 360;
        myanti_aircraftbitmap.scaleX = 0.3;
        myanti_aircraftbitmap.scaleY = 0.3;
        myanti_aircraftbitmap.visible = false;
        gameStage.addChild(myanti_aircraftbitmap);

        myanti_aircraftamong = new createjs.Text(player.anti_aircraft_tank, "30px sans-serif", "white");
        myanti_aircraftamong.x = 1130;
        myanti_aircraftamong.y = 370;
        myanti_aircraftamong.visible = false;
        gameStage.addChild(myanti_aircraftamong);


        mylight_armobitmap = new createjs.Bitmap(light_armo.image);
        mylight_armobitmap.x = 1030;
        mylight_armobitmap.y = 422;
        mylight_armobitmap.scaleX = 0.3;
        mylight_armobitmap.scaleY = 0.3;
        mylight_armobitmap.visible = false;
        gameStage.addChild(mylight_armobitmap);


        mylight_armoamong = new createjs.Text(player.light_armo, "30px sans-serif", "white");
        mylight_armoamong.x = 1130;
        mylight_armoamong.y = 432;
        mylight_armoamong.visible = false;
        gameStage.addChild(mylight_armoamong);


    }


    function Myship() {
        myaircraft_carrierbitmap = new createjs.Bitmap(aircraft_carrier.image);
        myaircraft_carrierbitmap.x = 804;
        myaircraft_carrierbitmap.y = 360;
        myaircraft_carrierbitmap.scaleX = 0.3;
        myaircraft_carrierbitmap.scaleY = 0.3;
        myaircraft_carrierbitmap.visible = false;
        gameStage.addChild(myaircraft_carrierbitmap);

        myaircraft_carrieramong = new createjs.Text(player.aircraft_carrier, "30px sans-serif", "white");
        myaircraft_carrieramong.x = 900;
        myaircraft_carrieramong.y = 363;
        myaircraft_carrieramong.visible = false;
        gameStage.addChild(myaircraft_carrieramong);


        myassault_shipbitmap = new createjs.Bitmap(assault_ship.image);
        myassault_shipbitmap.x = 804;
        myassault_shipbitmap.y = 422;
        myassault_shipbitmap.scaleX = 0.3;
        myassault_shipbitmap.scaleY = 0.3;
        myassault_shipbitmap.visible = false;
        gameStage.addChild(myassault_shipbitmap);

        myairassault_shipamong = new createjs.Text(player.assault_ship, "30px sans-serif", "white");
        myairassault_shipamong.x = 900;
        myairassault_shipamong.y = 432;
        myairassault_shipamong.visible = false;
        gameStage.addChild(myairassault_shipamong);

    }

    function Mysoldier() {

        mysoldierbitmap = new createjs.Bitmap(soilder.image);
        mysoldierbitmap.x = 804;
        mysoldierbitmap.y = 360;
        mysoldierbitmap.scaleX = 0.3;
        mysoldierbitmap.scaleY = 0.3;
        mysoldierbitmap.visible = false;
        gameStage.addChild(mysoldierbitmap);

        mysoldieramong = new createjs.Text(player.soilder, "30px sans-serif", "white");
        mysoldieramong.x = 900;
        mysoldieramong.y = 363;
        mysoldieramong.visible = false;
        gameStage.addChild(mysoldieramong);

    }


})();